using System.Collections.Specialized;
using Twipler.App.Entity;

namespace Twipler.App.AsyncCommands
{
	public class SuggestNameCommand : AsyncCommand
	{
		private string _s;
		private string _e;
		private string _word;
		
		public SuggestNameCommand(NameValueCollection collection)
		{
			// Start and End passback parameters
			_s = collection["s"] ?? "0";
			_e = collection["e"] ?? "0";

			_word = (collection["name"] ?? "").Trim();

			if (_word.StartsWith("@") && _word.Length > 1)
			{ 
				_word = Users.ScreenNameLike(_word);
				if (_word.Length > 0)
					_word = "@" + _word;
			}
			else
				_word = "";
		}

		public override string Render()
		{
			return string.Format("{0} {1} {2}", _s.Trim(), _e.Trim(), _word.Trim());
		}
	}
}